<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<title>用户注册</title>
<script type="text/javascript">
	$(document).ready(function(){
		$('#regbtn').click(function(){
				if(!$('#userName').val() || !$('input[name=password]').val()){
					alert('用户名和密码不能为空！');
					return false;
				}
				$.ajax({
					url:'${pageContext.request.contextPath}/user/registerAction',
					data:$('#userForm').serialize(),
					dataType:'json',
					type:'post',
					async:true,
					success:function(jsonData){
						if(jsonData.tip){
							alert("注册成功！");
							window.location.href="${pageContext.request.contextPath}/index.jsp";
						}else{
							alert(jsonData.errorStr);
						}
					}
				});
		});		
	});
</script>
</head>
<body>
	<center><form id="userForm">
		用户名：<input type="text" name="userName" id="userName"/><br/>
		密码：<input type="password" name="password"/><br/>
		邮箱：<input type="text" name="email"/>
		<button id="regbtn" type="button">注册</button>
	</form>
	</center>
</body>
</html>